#!/bin/sh -efu
# remove extra packages from a bare livecd

if [ -n "$GLOBAL_VERBOSE" ]; then
	echo "** GLOBAL_CLEANUP_PACKAGES: $GLOBAL_CLEANUP_PACKAGES"
	echo "** GLOBAL_CLEANUP_LIVE_PACKAGES: $GLOBAL_CLEANUP_LIVE_PACKAGES"
fi >&2

[ -z "$GLOBAL_CLEANUP_PACKAGES" ] && [ -z "$GLOBAL_CLEANUP_LIVE_PACKAGES" ] &&
	exit 0

CLEANUP_PACKAGES="$GLOBAL_CLEANUP_PACKAGES $GLOBAL_CLEANUP_LIVE_PACKAGES"

list="$(rpmquery -a --qf='%{NAME}\n' $CLEANUP_PACKAGES)"
[ -z "$list" ] || apt-get remove -f -y -- $list
:
